package com.neusoft.neuiotms.dcom.repository.incident.impl;

import com.neusoft.bizcore.web.jpa.repository.AbstractRepository;
import com.neusoft.neuiotms.dcom.model.incident.IncidentAppoint;
import com.neusoft.neuiotms.dcom.model.incident.QIncidentAppoint;
import com.neusoft.neuiotms.dcom.repository.incident.CustomizedIncidentAppointRepository;
import com.querydsl.jpa.impl.JPAQuery;

/**
 * @author WYS
 * @date 2020年8月18日 下午2:10:01
 */
public class CustomizedIncidentAppointRepositoryImpl extends AbstractRepository
        implements CustomizedIncidentAppointRepository {

    @Override
    protected Class<?> getModelClass() {
        return IncidentAppoint.class;
    }

    @Override
    public IncidentAppoint findByWorkNum(final String workOrderNum) {
        final QIncidentAppoint qIncidentAppoint = QIncidentAppoint.incidentAppoint;
        final JPAQuery<IncidentAppoint> query = this.query().selectFrom(qIncidentAppoint);
        query.where(qIncidentAppoint.workNum.eq(workOrderNum)).orderBy(qIncidentAppoint.createTime.desc()).limit(1);
        return query.fetchOne();
    }

}
